package com.superb.common.security.feign;

import com.superb.common.core.model.Result;
import com.superb.common.security.entity.Organization;
import com.superb.common.security.entity.SuperbTenant;
import com.superb.common.security.entity.SuperbUser;
import com.superb.common.security.entity.SuperbUserDataScope;
import org.springframework.cloud.openfeign.FeignClient;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;

import java.util.List;

/**
 * 远程用户获取
 *
 * @Author: ajie
 * @CreateTime: 2024-05-15 15:02
 */
@FeignClient(contextId = "remoteSecuritySystemService", value = "${superb.custom.feign.system:superb-system-biz}")
public interface RemoteSecuritySystemService {
    String SECURITY = "security/";

    /**
     * 获取租户信息
     *
     * @return
     */
    @GetMapping(SECURITY + "getTenantInfo")
    Result<SuperbTenant> getTenantInfo();

    /**
     * 通过用户ID获取用户信息
     *
     * @param id
     * @return
     */
    @GetMapping(SECURITY + "getUserById/{id}")
    Result<SuperbUser> getUserById(@PathVariable("id") String id);

    /**
     * 通用用户ID获取用户角色列表
     *
     * @param id
     * @return
     */
    @GetMapping(SECURITY + "getUserRoleList/{id}")
    Result<List<String>> getUserRoleList(@PathVariable("id") String id);

    /**
     * 通用用户ID获取用户权限列表
     *
     * @param id
     * @return
     */
    @GetMapping(SECURITY + "getUserPermissionList/{userId}")
    Result<List<String>> getUserPermissionList(@PathVariable("userId") String id);

    /**
     * 获取当前用户部门
     *
     * @return
     */
    @GetMapping(SECURITY + "getOrganization")
    Result<Organization> getOrganization();

    /**
     * 获取当前用户部门
     *
     * @return
     */
    @GetMapping(SECURITY + "getOrganizationIds/{organId}")
    Result<List<String>> getOrganizationIds(@PathVariable String organId);

    /**
     * 获取当前用户的数据权限范围
     *
     * @return
     */
    @GetMapping(SECURITY + "getUserDataScope")
    Result<SuperbUserDataScope> getUserDataScope();

    /**
     * 远程获取表字段是否存在索引
     *
     * @param table
     * @param column
     * @return
     */
    @GetMapping(SECURITY + "getDatabaseIndex/{table}/{column}")
    Result<String> getDatabaseIndex(@PathVariable String table, @PathVariable String column);

    /**
     * 远程获取表字段是否存在字段
     *
     * @param table
     * @param column
     * @return
     */
    @GetMapping(SECURITY + "getExistColumn/{table}/{column}")
    Result<Boolean> getExistColumn(@PathVariable String table, @PathVariable String column);

}
